﻿using System.Data;
using System.Dynamic;
using SqlSugar;
using WeDonekRpc.Model;
using WeDonekRpc.SqlSugar.VirtualQuery;

namespace WeDonekRpc.SqlSugar
{
    public interface IVirtualRepository
    {
        SqlSugarProvider Provider { get; }

        ILocalTransaction ApplyTran ( bool isInherit = true );

        int Count ( string table, List<IConditionalModel> where );

        IVirtualTable CreateTable ( string tableName, string show );

        IVirtualQueue BeginQueue ();

        IVirtualQuery GetVirtualTable ( QueryStruct query );

        void CreateTable<T> () where T : class;

        void CreateTable<T> ( string tableName ) where T : class;

        bool Delete<IdentityId> ( string table, string col, IdentityId value );

        bool Delete<IdentityId> ( string table, string col, IdentityId[] value );

        ExpandoObject Get ( string table, List<IConditionalModel> where );

        ExpandoObject Get ( string table, List<IConditionalModel> where, List<SelectModel> selects );

        ExpandoObject Get ( string table, List<IConditionalModel> where, params string[] cols );

        Result Get<Result> ( string table, List<IConditionalModel> where, string colName );

        ExpandoObject[] GetAll ( string table );

        Result[] GetAll<Result> ( string table, string colName );

        ISugarQueryable<ExpandoObject> GetQueryable ( string table );

        ISugarQueryable<ExpandoObject> GetQueryable ( string table, List<IConditionalModel> where );

        ExpandoObject[] Gets ( string table, List<IConditionalModel> where );

        ExpandoObject[] Gets ( string table, List<IConditionalModel> where, List<SelectModel> selects );

        ExpandoObject[] Gets ( string table, List<IConditionalModel> where, string[] selects );

        ExpandoObject[] Gets ( string table, List<SelectModel> selects );

        Result[] Gets<Result> ( string table, List<IConditionalModel> where, string colName );
        void Insert ( string table, Dictionary<string, object> values );

        int Insert ( DataTable table );

        void Insert ( string table, Func<object> values );

        bool IsTable ( string tableName );

        Result Max<Result> ( string table, List<IConditionalModel> where, string colName );

        Result Min<Result> ( string table, List<IConditionalModel> where, string filed );

        ExpandoObject[] Query ( string table, List<IConditionalModel> where, List<SelectModel> selects, IBasicPage pager, out int count );

        ExpandoObject[] Query ( string table, IBasicPage pager, out int count );
        ExpandoObject[] Query ( string table, List<IConditionalModel> where, IBasicPage pager, out int count );

        ExpandoObject[] Query ( string table, List<IConditionalModel> where, string[] cols, IBasicPage pager, out int count );

        ExpandoObject[] GroupBy ( string table, List<IConditionalModel> where, List<SelectModel> selects, List<GroupByModel> groupBy );

        IUpdateable<object> Update ( string table );

        bool Update ( string table, Dictionary<string, object> values, string identityId );

        bool Update ( string table, Dictionary<string, object> values, string[] identityIds );

        bool Update ( string table, Func<object> values, string identityId );

        bool Update ( string table, Func<object> values, string[] identityId );

        bool IsExists ( string table, List<IConditionalModel> where );
        bool IsExists ( string table, List<IConditionalModel> where, string col );
    }
}